import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/layout/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/dashboard',
      name: 'layout',
      component: Layout,
      hidden: true
    },
    {
      path: '/dashboard',
      name: 'dashboard',
      component: () => import('@/views/dashboard/index.vue'),
      meta: {
        title: '工作台'
      }
    },
    {
      path: '/login',
      name: 'login',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('@/views/login/index.vue'),
      hidden: true
    },
    {
      path: '/system',
      name: 'system',
      redirect: '/system/permission',
      meta: {
        title: '系统管理'
      },
      children: [
        {
          path: '/system/permission',
          name: 'permission',
          redirect: '/system/permission/user',
          meta: {
            title: '权限管理'
          },
          children: [
            {
              path: '/system/permission/user',
              name: 'user',
              component: () => import('@/views/system/permission/user/index.vue'),
              meta: {
                title: '用户管理'
              }
            },
            {
              path: '/system/permission/role',
              name: 'role',
              component: () => import('@/views/system/permission/role/index.vue'),
              meta: {
                title: '角色管理'
              }
            }
          ]
        }
      ]
    }
  ]
})

export default router
